<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/base.js"></script>
</head>
<body>
<h1>新增课程</h1>
课程编号:<span id="cid"></span><br>
课程名称:<input id="name"/><br>
授课教师:<input id="teacherName"/><br>
教室容量:<span id="sMax"></span><br><br>
<button style="position: relative; left: 68px;" onclick="onSaveClick();">确认保存</button>
<script>
    window.onload=function () {
        let cid=sessionStorage.getItem("cid");
        let name=sessionStorage.getItem("name");
        let teacherName=sessionStorage.getItem("teacherName");
        let sMax=sessionStorage.getItem("sMax");
        document.getElementById("cid").innerHTML=cid;
        document.getElementById("name").value=name;
        document.getElementById("teacherName").value=teacherName;
        document.getElementById("sMax").innerHTML=sMax;
    };
    function onSaveClick() {
        let json={};
        json.cid=document.getElementById("cid").innerHTML;
        json.name=document.getElementById("name").value;
        json.teacherName=document.getElementById("teacherName").value;

        let url="http://localhost:9001/Demo/course/course";
        let method="put";
        $.rest(method,url,json,function (r) {
            if (r.code==200){
                window.location.href="teacher.html";
            }
        });
    }
</script>
</body>
</html>